#include <bits/stdc++.h>
#define int long long 
using namespace std;

const int N = 2e5 + 5;
int arr[N];
int prefix[N];

void solve(){
	int n, k;
	cin >> n >>k ;
	for (int i=1; i<=n;i++) {
		cin >> arr[i];
	}
	sort(arr+1, arr+1+n);
	for (int i=1; i<=n;i++) {
		prefix[i] = prefix[i-1] + arr[i];
	}
	int minn = 1e18;
	for (int i=1; i<=k;i++) {
		int sum1 = prefix[i*2];
		int sum2 = prefix[n] - prefix[n-(k-i)];
		minn = min(minn, sum1 + sum2);
	}
	cout << (prefix[n]-minn) << '\n';
	
}



signed main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t ;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
